<div class="edit-div">
    <button class="layui-btn  layui-btn-normal">新增</button>
</div>
<table id="roles" lay-filter="roles"></table>
<script>
    layui.use('table', function(){
        var table = layui.table;

        //第一个实例
        table.render({
            elem: '#roles',
            url: '/systemRole/getRoleList', //数据接口
            method: 'post',
            page: true, //开启分页
            cols: [[ //表头
                {field: 'id', title: 'ID', fixed: 'left'}
                ,{field: 'name', title: '名称' }
                ,{field: 'creator', title: '创建人'}
                ,{field: 'createTime', title: '创建时间',
                    templet: function(d){
                        return new Date(d.createTime).Format('yyyy-MM-dd hh:mm:ss');
                    }
                }
                ,{field: 'modifier', title: '修改人'}
                ,{field: 'createTime', title: '修改时间',
                    templet: function(d){
                        return new Date(d.createTime).Format('yyyy-MM-dd hh:mm:ss');
                    }
                },
                {field:'right', title: '操作', width:177,toolbar:"#edit-resource"}
            ]]
        });


        //监听工具条
        table.on('tool(roles)', function(obj){
            var data = obj.data;
            if(obj.event === 'edit'){
                forwardByUrlAndTitle("/systemResource/editResource?roleId="+data.id,"编辑权限");
            }
        });

    });
</script>
<script type="text/html" id="edit-resource">
    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑权限</a>
</script>